<?php
// 后台用户模块
class MemberAction extends CommonAction {
	function _filter(&$map){
		  $map['id'] = array('egt',2);
		$map['membername'] = array('like',"%".$_POST['membername']."%");
	}
	/**
	保存摄像头拍下的照片
	并返回图片路径
	**/

	function savephoto(){
	
	 if ($_POST['type'] == "pixel") {
	// input is in format 1,2,3...|1,2,3...|...
	$im = imagecreatetruecolor(320, 240);

	foreach (explode("|", $_POST['image']) as $y => $csv) {
		foreach (explode(";", $csv) as $x => $color) {
			imagesetpixel($im, $x, $y, $color);
		}
	}
	
	
} else {
	// input is in format: data:image/png;base64,...
	$im = imagecreatefrompng($_POST['image']);
}

imagejpeg($im,"scdtp.jpg"); 
echo 'scdtp.jpg';
exit;
	
		/* $str = file_get_contents("php://input");
		$name=uniqid().".jpg";
		file_put_contents("/Public/Upload/Photos/".$name, pack("H*", $str)); */
		//echo "/Public/Upload/Photos/".$name;
	}	
	function upload(){
	if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
	$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
	
	// Validate the file type
	$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	
	if (in_array($fileParts['extension'],$fileTypes)) {
		move_uploaded_file($tempFile,$_FILES['Filedata']['name']);
		echo $_FILES['Filedata']['name'];
	} else {
		echo 'Invalid file type.';
	}
}
	}
}
?>